package com.jeesite.modules.flow.entity;

import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.lang.ObjectUtils;
import com.jeesite.common.lang.StringUtils;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.Table;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.Date;

/**
 * 待办事项对象 biz_todo_item
 *
 * @author Xianlu Tech
 * @date 2019-11-08
 */
@Table(name="biz_todo_item", alias="a", label="待办事项", columns={
        //@Column(name="id", attrName="id", label="编号", isPK=true),
        @Column(name="id", attrName="tid", label="编号", isPK=true),
        @Column(name="item_name", attrName="itemName", label="事项标题"),
        @Column(name="item_content", attrName="itemContent", label="事项内容"),
        @Column(name="module", attrName="module", label="模块名称 (必须以 uri 一致)"),
        @Column(name="task_id", attrName="taskId", label="任务 ID"),
        @Column(name="instance_id", attrName="instanceId", label="流程实例 ID"),
        @Column(name="task_name", attrName="taskName", label="任务名称 (必须以表单页面名称一致)"),
        @Column(name="node_name", attrName="nodeName", label="节点名称"),
        @Column(name="is_view", attrName="isView", label="是否查看 default 0 (0 否 1 是)"),
        @Column(name="is_handle", attrName="isHandle", label="是否处理 default 0 (0 否 1 是)"),
        @Column(name="todo_user_id", attrName="todoUserId", label="待办人 ID"),
        @Column(name="todo_user_name", attrName="todoUserName", label="待办人名称"),
        @Column(name="handle_user_id", attrName="handleUserId", label="处理人 ID"),
        @Column(name="handle_user_name", attrName="handleUserName", label="处理人名称"),
        @Column(name="todo_time", attrName="todoTime", label="通知时间"),
        @Column(name="handle_time", attrName="handleTime", label="处理时间"),
}, orderBy="a.todo_time DESC"
)
public class BizTodoItem extends DataEntity<BizTodoItem> {

    private static final long serialVersionUID = 1L;

    /** 主键 ID */
    private String id;

    private Long tid;	// 增加表自增主键存储属性

    /** 事项标题 */
    private String itemName;

    /** 事项内容 */
    private String itemContent;

    /** 模块名称 (必须以 uri 一致) */
    private String module;

    /** 任务 ID */
    private String taskId;

    /** 流程实例 ID */
    private String instanceId;

    /** 任务名称 (必须以表单页面名称一致) */
    private String taskName;

    /** 节点名称 */
    private String nodeName;

    /** 是否查看 default 0 (0 否 1 是) */
    private String isView;

    /** 是否处理 default 0 (0 否 1 是) */
    private String isHandle;

    /** 待办人 ID */
    private String todoUserId;

    /** 待办人名称 */
    private String todoUserName;

    /** 处理人 ID */
    private String handleUserId;

    /** 处理人名称 */
    private String handleUserName;

    /** 通知时间 */
    private Date todoTime;

    /** 处理时间 */
    private Date handleTime;

    /**
     * 重载插入前执行的方法，setId 为 null，使用数据自增
     */
    @Override
    public void preInsert() {
        super.preInsert();
        setId(null);
    }

    /**
     * 重载默认方法，主键类型互转，方便前端操作
     * 如果需要在 insert 后返回 自增ID，请设置 mybatis-config.xml 的 useGeneratedKeys="true"
     */
    @Override
    public String getId() {
        return ObjectUtils.toString(getTid());
    }

    /**
     * 重载默认方法，主键类型互转，方便前端操作
     */
    @Override
    public void setId(String id) {
        setTid(StringUtils.isNotBlank(id) ? Long.parseLong(id) : null);
    }

    /**
     * 自增字段的 get
     */
    public Long getTid() {
        return tid;
    }

    /**
     * 自增字段的 set
     */
    public void setTid(Long tid) {
        this.tid = tid;
    }

    public void setItemName(String itemName) {
        this.itemName = itemName;
    }

    public String getItemName() {
        return itemName;
    }
    public void setItemContent(String itemContent) {
        this.itemContent = itemContent;
    }

    public String getItemContent() {
        return itemContent;
    }
    public void setModule(String module) {
        this.module = module;
    }

    public String getModule() {
        return module;
    }
    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }

    public String getTaskId() {
        return taskId;
    }
    public void setTaskName(String taskName) {
        this.taskName = taskName;
    }

    public String getNodeName() {
        return nodeName;
    }

    public void setNodeName(String nodeName) {
        this.nodeName = nodeName;
    }

    public String getTaskName() {
        return taskName;
    }
    public void setIsView(String isView) {
        this.isView = isView;
    }

    public String getIsView() {
        return isView;
    }
    public void setIsHandle(String isHandle) {
        this.isHandle = isHandle;
    }

    public String getIsHandle() {
        return isHandle;
    }
    public void setTodoUserId(String todoUserId) {
        this.todoUserId = todoUserId;
    }

    public String getTodoUserId() {
        return todoUserId;
    }
    public void setTodoUserName(String todoUserName) {
        this.todoUserName = todoUserName;
    }

    public String getTodoUserName() {
        return todoUserName;
    }
    public void setHandleUserId(String handleUserId) {
        this.handleUserId = handleUserId;
    }

    public String getHandleUserId() {
        return handleUserId;
    }
    public void setHandleUserName(String handleUserName) {
        this.handleUserName = handleUserName;
    }

    public String getHandleUserName() {
        return handleUserName;
    }
    public void setTodoTime(Date todoTime) {
        this.todoTime = todoTime;
    }

    public Date getTodoTime() {
        return todoTime;
    }
    public void setHandleTime(Date handleTime) {
        this.handleTime = handleTime;
    }

    public Date getHandleTime() {
        return handleTime;
    }

    public String getInstanceId() {
        return instanceId;
    }

    public void setInstanceId(String instanceId) {
        this.instanceId = instanceId;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("itemName", getItemName())
            .append("itemContent", getItemContent())
            .append("module", getModule())
            .append("instanceId", getInstanceId())
            .append("taskId", getTaskId())
            .append("taskName", getTaskName())
            .append("isView", getIsView())
            .append("isHandle", getIsHandle())
            .append("todoUserId", getTodoUserId())
            .append("todoUserName", getTodoUserName())
            .append("handleUserId", getHandleUserId())
            .append("handleUserName", getHandleUserName())
            .append("todoTime", getTodoTime())
            .append("handleTime", getHandleTime())
            .toString();
    }
}
